#pragma once
#include <chrono>
#include <functional>

// 获取运行时间的毫秒数
double get_execution_time(std::function<void(void)> closure) {
    for (int i = 0; i < 5; i++) { // warm up
        closure();
    }
    auto beforeTime = std::chrono::steady_clock::now();
    for (int i = 0; i < 10; i++) {
        closure();
    }
    auto afterTime = std::chrono::steady_clock::now();

    double duration =
        std::chrono::duration<double, std::milli>(afterTime - beforeTime).count() / 10.0;
    return duration;
}
